//user_status单一的user_status表SQL-Command
var user_status = {
    insertOne:'INSERT INTO user (pid,id,' +
    ' name,address,age,icon,discount,creationTime,sex,status,inviCode,password,perstatus,readyper)' +
    ' VALUES(?,?,?,?,?,?,?,?,?,?,?,?,0,0)',
    findAll:'select * from user where status=1',
    findOne:'SELECT *FROM user WHERE id=?',
    findOneByInvi:'SELECT *FROM user WHERE inviCode=?',
    findMaxOne:'select max(id) maxid from user;',
    deleteUserById:'delete from user where id = ?',
    updateOneInfoAction:'update user set name = ?,address = ?,age = ?,icon = ?,discount = ?,creationTime = ?,sex =?' +
    ' where id = ?',
    findAllType:'select DISTINCT type from user',
    lessThan3G:'select user.name,grade.title from user,grade where user.grade=grade.grade and user.type=grade.type' +
    ' and user.grade<3 and user.type=?',
    insertThereIcons:'INSERT INTO userIcon (id,iconId,icon1,icon2,icon3) VALUES(?,?,?,?)',
    findAllApply:"select * from user where status = '0'",
    rejectApply:"update user set status= 'no' where id = ?",
    passApply:"update user set status= 1 where id = ?",
    //递归查询父节点
    findPid:'select * from user where FIND_IN_SET(id,getParentList(?))',
    updateDiscount:'update user set discount = ? where id = ?',
    login:'select *from user where name = ? and password = ?',
    persent:'update user set persent = persent + ? where id = ?',
    persent1:'update user set perstatus = 1 where id = ?',
    persent2:'update user set perstatus = 2 where id = ?',
    persent3:'update user set perstatus = 3,persent = 0 where id = ?',
    persent4:'update user set readyper = readyper + ? where id = ?',
};
var prod_status = {
    insertOneSpec:'INSERT INTO prodspec (color,spec)' +
    ' VALUES(?,?)',
    findAll:'select * from prod',
    findByName:"select * from prod where name like ? ",
    deteleProdById:'delete from prod where id = ?',
    insertOne:'INSERT INTO prod (name,qty,icon,sales,price,creationTime,description,color,spec)' +
    ' VALUES(?,?,?,?,?,?,?,?,?)',
    findSpecItem:'select a.name,b.specKey,b.specValue from prod a,prodSpec b where a.id=b.id and a.id = 321;',
    findSpec:'select * from prodspec',
    findOneById:'select * from prod where id = ?',
    updateById:'update prod set name = ?,qty=?,icon = ?,price=?,creationTime=?,description=?,color=?,spec=? where' +
    ' id=?'
};
var order_status = {
    insertOne:'INSERT INTO carts (prodId,prodName,quan,total,attr,ct,status,icon,userId)' +
    ' VALUES(?,?,?,?,?,?,?,?,?)',
    findAll:'select * from carts',
    findAllOrder:'select * from carts where userId = ? and status = 0',
    findDiscount:'select * from percentage',
    deteleById:'delete from carts where id = ?',
    confirmById:'update carts set status = 1 where id = ?',
    regretById:'update carts set status = 0 where id = ?'
    // updateStatus:'update carts set st'
}
//exports
module.exports = {
    user_status: user_status,
    prod_status:prod_status,
    order_status:order_status
};
